package com.example.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.example.entity.RolesEntity;
import com.example.service.RolesService;
@RequestMapping("/roles")
@Controller
public class RolesController {
	
	@Autowired
	private RolesService rolesService;
	
	@RequestMapping(path="/find")
	@ResponseBody
	public Map<String, Object> find() {
		Map<String, Object> relMap=new HashMap<String, Object>();
		List<RolesEntity> list=rolesService.find();
		relMap.put("code", "0");
		relMap.put("msg", "success");
		relMap.put("count", "");
		relMap.put("data", list);
		return relMap;
	}
	
	/**
	 * 新增
	 * @param me
	 * @return
	 */
	@RequestMapping("/addRoles")
	@ResponseBody
	public boolean addRoles(RolesEntity roles){
		return rolesService.addRoles(roles)>0 ? true:false;
	}
	
	/**
	 * 修改
	 * @param me
	 * @return
	 */
	@RequestMapping("/upRoles")
	@ResponseBody
	public boolean upRoles(RolesEntity roles){
		return rolesService.upRoles(roles)>0 ? true:false;
	}
	
	/**
	 * 删除
	 * @param id
	 * @return
	 */
	@RequestMapping("/delRoles")
	@ResponseBody
	public boolean delRoles(Integer id){
		return rolesService.delRoles(id)>0 ? true:false;
	}
}
